<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <t:base type="jquery,easyui,tools,DatePicker,ckeditor"></t:base>

    <link rel="stylesheet" href="${webRoot}/plug-in/custom_style/css/style.css"/>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/blue.css"/>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/default.css"/>
    <script type="text/javascript" src="${webRoot}/plug-in/ajaxfileupload/ajaxfileupload.js"></script>


    <script type="text/javascript">
        function noteSubmitCallback(data) {
            tip(data.msg);
        }

        function saveNoteInfo() {
            //type1 自定义按钮提交
            //iframe = frameElement.contentWindow;
            //saveObj();

            //type2 直接提交
            //$('#btn_sub').click();

            //type3重写 callback函数防止关闭
            $('#btn_sub').click();
        }

        //Ajax文件上传
        function f_file_upload(fileInputId, imgId, valueId) {
            var path = $("#" + fileInputId).val();
            var pos1 = path.lastIndexOf("\\");
            var pos2 = path.lastIndexOf(".");

            var fileName = path.substring(pos1 + 1, pos2);

            var result = path.substring(pos2 + 1, path.length);

            var imgs = ".bmp.jpg.dib.jpeg.png.jfif.jpe.tif.tiff.gif.BMP.JPG.DIB.JPEG.PNG.JFIF.JPE.TIF.TIFF.GIF";
            //文件类型 false为压缩包
            var boo = false;
            if (imgs.indexOf(result) > -1) {
                boo = true;
            } else {
                tip(" 只能上传后缀为 " + imgs + " 的文件！");
                $("#" + fileInputId).val("");
                return;
            }

            $.ajaxFileUpload({
                url: '${webRoot}/myFileUpload/uploadImageScale.do',
                secureuri: false,
                fileElementId: fileInputId,
                //dataType: 'json',
                success: function (data) {
                    var data2 = data.split(",");
                    var url = data2[0].replace(" ", "");
                    fileName = data2[1].replace(" ", "");

                    $("#" + imgId).attr("src", "${webRoot}/" + url);
                    $("#" + valueId).val(url);
                },
                error: function (data) {

                    console.log("error");
                    console.log(data);
                }
            });
        }
    </script>
</head>

<body scroll="no">
<t:formvalid formid="addformobj" dialog="true" usePlugin="password" layout="table"
             action="bankController.do?saveorupdate">
    <%--callback="@Override noteSubmitCallback"--%>


    <input name="id" type="hidden" value="${bank.id}">

    <div class="new_table_list">
        <table cellpadding="0" cellspacing="1" class="formtable">
            <tbody>
            <tr>
                <th colspan="4">银行卡信息</th>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        银行名称:
                    </label>
                </td>
                <td class="txt_left value" colspan="3">
                    <input class="inputxt" style="width: 250px;" name="name" value="${bank.name}" datatype="*" maxlength="128">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <label class="Validform_label">
                        银行logo:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="logoThumbImg"
                         src='${webRoot}/${bank.logo==null||bank.logo==""?"upload/defCodeset.png":bank.logo}'
                         class="viewimg" alt="预览" title="预览" width="50px;" height="50px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="logo"
                           onchange="f_file_upload('logo','logoThumbImg','logoThumb')"/>
                    <input type="hidden" name="logo" id="logoThumb"
                           value='${bank.logo==null?"upload/defCodeset.png":bank.logo}'/>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <label class="Validform_label">
                        银行卡背景图片:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="backgroupThumbImg"
                         src='${webRoot}/${bank.backgroup==null||bank.backgroup==""?"upload/defCodeset.png":bank.backgroup}'
                         class="viewimg" alt="预览" title="预览" width="400px;" height="200px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="backgroup"
                           onchange="f_file_upload('backgroup','backgroupThumbImg','backgroupThumb')"/>
                    <input type="hidden" name="backgroup" id="backgroupThumb"
                           value='${bank.backgroup==null?"upload/defCodeset.png":bank.backgroup}'/>
                </td>
            </tr>
        </table>
    </div>
</t:formvalid>
</body>

</html>